#region Using References

using System;
using System.Diagnostics.CodeAnalysis;
using Beaker.OpenCube.NbtEditor.ViewModels;

#endregion

namespace Beaker.OpenCube.Specs.NbtEditor.ViewModels.Builders
{
	/// <summary>
	/// Dummy viewmodel that inherits from the abstract viewmodel base
	/// so we can create an instance of it.
	/// With basic implementation of property verify if SetAndRaiseIfChanged works
	/// </summary>
	[ExcludeFromCodeCoverage]
	public sealed class ViewModelTester
		: ViewModel
	{
		private readonly Action<string, string> _onValueChanged;

		public ViewModelTester( string value, Action<string, string> onValueChanged )
		{
			_propertyValue = value;
			_onValueChanged = onValueChanged;
		}

		private string _propertyValue;

		public string Value
		{
			get { return _propertyValue; }
			set
			{
				// if no handler given, we must use the method without handler (actual default param of null)
				// otherwise the method with the handler
				if( _onValueChanged == null )
					SetAndRaiseIfChanged( ref _propertyValue, value );
				else
					SetAndRaiseIfChanged( ref _propertyValue, value, _onValueChanged );
			}
		}

	}
}